package goylc

/////////////////////////////////// raw ///////////////////////////////////////
type GoylcStateSet struct {
	container map[*GoylcState]struct{}
}

func (set *GoylcStateSet) Add(some *GoylcState) {
	set.container[some] = struct{}{}
}

func (set *GoylcStateSet) Clear() {
	set.container = map[*GoylcState]struct{}{}
}

func (set *GoylcStateSet) Remove(some *GoylcState) {
	delete(set.container, some)
}

func (set *GoylcStateSet) Contains(some *GoylcState) bool {
	_, ok := set.container[some]
	return ok
}

func (set *GoylcStateSet) Len() int64 {
	size := int64(len(set.container))
	return size
}

func (set *GoylcStateSet) ToSlice() []*GoylcState {
	ss := make([]*GoylcState, 0, set.Len())
	for k, _ := range set.container {
		ss = append(ss, k)
	}
	return ss
}

func (set *GoylcStateSet) Pop() *GoylcState {
	var val *GoylcState = nil
	for k, _ := range set.container {
		val = k
		break
	}

	if val != nil {
		set.Remove(val)
	}
	return val
}

func NewGoylcStateSet() *GoylcStateSet {
	return &GoylcStateSet{
		container: make(map[*GoylcState]struct{}, 10),
	}
}
